Fix MongoDB query safety, auth bypass, and devicestatus refactor#1
Open
sergev-art wants to merge 1 commit intomasterfrom
Open
Fix MongoDB query safety, auth bypass, and devicestatus refactor#1sergev-art wants to merge 1 commit intomasterfrom
sergev-art wants to merge 1 commit intomasterfrom
Conversation
Co-authored-by: bewest <394179+bewest@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses three safety-critical issues identified in upstream review (nightscout#8447, nightscout#8421):
lib/server/query.js):updateIdQuerycrashed on UUID-format_idvalues. Now validates 24-char hex pattern before coercing to ObjectID.lib/authorization/delaylist.js):authFailDelay = 0was silently accepted via|| 5000fallback, eliminating brute-force protection. Replaced with explicit positive-finite guard.lib/server/devicestatus.js): Replaced serialinsertOneloop withinsertMany. AddedtruncatePredictions(obj, maxSize)to cap prediction arrays at 288 points (24h × 5min), preventing MongoDB 16MB document limit breach. ModernizedremovetodeleteMany.lib/server/bootevent.js): Updated call signature to match refactored devicestatus module.Design Control Impact
This PR affects the following design control areas:
Modified Requirements
New Test Cases Needed
tests/query.test.js)truncatePredictionsboundary conditions (at/below/above 288 points)insertManybatch behavior vs. former serialinsertOneauthFailDelaywith values:0, positive integer, missing/undefined, non-numericTest Modifications
storage(collection, ctx)→storage(env, ctx))Risk Items
Files Changed (5)
lib/server/query.jslib/authorization/delaylist.jslib/server/devicestatus.jslib/server/bootevent.jstests/query.test.js